package com.yesido.springcloud.feign.service;

import com.yesido.pojo.User;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;

import java.util.List;

/**
 * @author yesido
 * @date 2023-06-06
 */
@Component
@FeignClient(value = "myprovider",fallbackFactory = ClientServiceFallbackFactory.class) // 还是通过服务名字 底层用ribbon去访问
public interface FeignService {

    /**
     *  需要是provider接口的全路径
     *  /pd1/findUserById/{id} 必须和provider中的全路一致
     */
    @GetMapping("/pd1/findUserById/{id}")
    public User getUserById( @PathVariable("id") int id );
    /**
     * 查询所有
     */
    @GetMapping("/pd1/findAllUsers")
    public List<User> findAllUsers();



    @PostMapping("/pd1/addUser")
    public int addUser( User user);
}
